package io.renren.modules.generator.service.impl;

import io.renren.modules.generator.dao.MyUserDao;
import io.renren.modules.generator.service.MyUserService;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;


import io.renren.modules.generator.entity.MyUserEntity;



@Service("MyUserService")
public class UserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> implements MyUserService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<MyUserEntity> wrapper = null;
        if (params.get("key")!=null){
            wrapper = new QueryWrapper<MyUserEntity>().and(
                    (item) -> {
                        item.like("nick_name", params.get("key"))
                                .or().like("address_code", params.get("key"))
                                .or().like("openid", params.get("key"));
                    }
            );
        }
        IPage<MyUserEntity> page = this.page(
                new Query<MyUserEntity>().getPage(params),wrapper
        );

        return new PageUtils(page);
    }

}